﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace RCU_Trial
{
    public class LunabotOutputState
    {
        #region Variables
        /// <summary>
        /// State of the collection bin shaker motor
        /// </summary>
        private bool collectionBinShaker;
        /// <summary>
        /// Desired position of the collection bin
        /// </summary>
        private float collectionBinPosition;
        /// <summary>
        /// Specifies whether the RoboteQ controllers should use closed loop or open loop control
        /// </summary>
        private bool closedLoopDriveControl;
        /// <summary>
        /// Desired position of the digging mechanism
        /// </summary>
        private float diggingMechanismPosition;
        /// <summary>
        /// Speed of the digging motor
        /// </summary>
        private float diggingMotorSpeed;
        /// <summary>
        /// Motor speed for both motors on the left side
        /// </summary>
        private float motorSpeedLeft;
        /// <summary>
        /// Motor speed for both motors on the right side
        private float motorSpeedRight;
        #endregion

        #region Constructor
        public LunabotOutputState()
        {
            // Set initial default values
            this.collectionBinShaker = false;
            this.closedLoopDriveControl = true;
            this.collectionBinPosition = 0;
            this.diggingMechanismPosition = 0;
            this.diggingMotorSpeed = 0;
            this.motorSpeedLeft = 0;
            this.motorSpeedRight = 0;
        }
        #endregion

        #region Methods
        public override bool Equals(System.Object obj)
        {
            /*return false if parameter is null*/
            if (obj == null)
                return false;

            /*if it can't be cast, return false*/
            LunabotOutputState state = obj as LunabotOutputState;
            if ((System.Object)state == null)
                return false;

            /*compare values*/
            return Equals(state);

        }

        public bool Equals(LunabotOutputState state)
        {
            if ((System.Object)state == null)
                return false;
            return (this.motorSpeedLeft == state.motorSpeedLeft) && (this.motorSpeedRight == state.motorSpeedRight)
                && (this.closedLoopDriveControl == state.closedLoopDriveControl) && (this.collectionBinPosition == state.collectionBinPosition)
                && (this.diggingMechanismPosition == state.diggingMechanismPosition) && (this.diggingMotorSpeed == state.diggingMotorSpeed)
                && (this.collectionBinShaker == state.collectionBinShaker);
        }

        /*including to maintain override requirements, although not used*/
        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * this.motorSpeedLeft.GetHashCode();
            hash = hash * this.motorSpeedRight.GetHashCode();
            hash = hash * this.closedLoopDriveControl.GetHashCode();
            hash = hash * this.collectionBinPosition.GetHashCode();
            hash = hash * this.collectionBinShaker.GetHashCode();
            hash = hash * this.diggingMotorSpeed.GetHashCode();
            hash = hash * this.diggingMechanismPosition.GetHashCode();

            return hash;
        }
        #endregion

        #region Parameters
        /// <summary>
        /// Desired position of the collection bin
        /// </summary>
        [Category("Collection Bin")]
        [DisplayName("Mechanism Position")]
        [Description("Specifies the desired position of the collection bin")]
        public float CollectionBinPosition
        {
            get { return collectionBinPosition; }
            set { collectionBinPosition = value; }
        }
        /// <summary>
        /// State of the collection bin shaker motor
        /// </summary>
        [Category("Collection Bin")]
        [DisplayName("Shaker Motor On")]
        [Description("State of the shaker motor on the collection bin")]
        public bool CollectionBinShaker
        {
            get { return collectionBinShaker; }
            set { collectionBinShaker = value; }
        }
        /// <summary>
        /// Specifies whether the RoboteQ controllers should use closed loop or open loop control
        /// </summary>
        [Category("Drivetrain")]
        [DisplayName("Closed Loop Control")]
        [Description("Specifies whether the RoboteQ controllers should use closed loop or open loop control")]
        public bool ClosedLoopDriveControl
        {
            get { return closedLoopDriveControl; }
            set { closedLoopDriveControl = value; }
        }
        /// <summary>
        /// Desired position of the digging mechanism
        /// </summary>
        [Category("Digging Mechanism")]
        [DisplayName("Mechanism Position")]
        [Description("Desired position of the digging mechanism")]
        public float DiggingMechanismPosition
        {
            get { return diggingMechanismPosition; }
            set { diggingMechanismPosition = value; }
        }
        /// <summary>
        /// Speed of the digging motor
        /// </summary>
        [Category("Digging Mechanism")]
        [DisplayName("Motor Speed")]
        [Description("Speed of the digging motor")]
        public float DiggingMotorSpeed
        {
            get { return diggingMotorSpeed; }
            set { diggingMotorSpeed = value; }
        }
        /// <summary>
        /// Motor speed for both motors on the left side of the robot
        /// </summary>
        [Category("Drivetrain")]
        [DisplayName("Left Motor Speed")]
        [Description("Motor speed for both motors on the left side of the robot")]
        public float MotorSpeedLeft
        {
            get { return motorSpeedLeft; }
            set { motorSpeedLeft = value; }
        }
        /// <summary>
        /// Motor speed for both motors on the right side
        /// </summary>
        [Category("Drivetrain")]
        [DisplayName("Right Motor Speed")]
        [Description("Motor speed for both motors on the right side")]
        public float MotorSpeedRight
        {
            get { return motorSpeedRight; }
            set { motorSpeedRight = value; }
        }
        #endregion
    }
}
